//
//  Address2.m
//  OC_08_类的扩展
//
//  Created by wyx on 16/3/7.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "Address2.h"
#import "Contact.h"
@interface Address2()
@property (nonatomic, retain)NSMutableDictionary *mDic;

@end
@implementation Address2
- (void)dealloc{
    [_mDic dealloc];
    [super dealloc];
}
- (instancetype)init{
    self = [super init];
    if (self) {
        self.mDic = [NSMutableDictionary dictionary];
    }
    return  self;
}
- (NSString *)firstCharacter:(NSString *)name{
    return [[name substringToIndex:1] uppercaseString];
 }
- (void)addContact:(Contact *)con {
    //获取首字母
    NSString *group = [self firstCharacter:con.name];
    NSMutableArray *arrOf = [self.mDic objectForKey:group];
    if (arrOf == nil) {
        [arrOf addObject:con];
        [self.mDic setObject:arrOf forKey:group];
    }
    else{
        [arrOf addObject:con];
    }
}
@end
